package erfgame.core;


public abstract class AbstractIdObject<T> {
	protected T id;
	
	public AbstractIdObject() {
	}
	
	public AbstractIdObject(T id) {
		this.id = id;
	}
	
	public T getId() {
		return this.id;
	}
	
	public int hashCode() {
		 return this.id.hashCode();
	 }
	 
	 public boolean equals( Object o ) {
		 if( o != null && o.getClass().equals( o.getClass() ) ) {
			 return equals( (AbstractIdObject<T>)o );
		 } else {
			 return false;
		 }
	 }
	 
	 public boolean equals( AbstractIdObject<T> o ) {
		 if( this.getId() != null ) {
			 return this.getId().equals(o.getId()); 
		 } else {
			 return false;
		 }
	 }

}
